package service;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import dao.Top10CategoryDao;
import dao.impl.Top10CategoryDaoImpl;
import domain.Top10Category;

import java.util.List;

public class Top10CategoryService {
    String valueAsString = null;
    private Top10CategoryDao contacts = new Top10CategoryDaoImpl();
    public String ToJson() {
        List<Top10Category> list = contacts.SelectAll();
        ObjectMapper objectMapper = new ObjectMapper();
        try {
            valueAsString = objectMapper.writeValueAsString(list);
        } catch (JsonProcessingException e) {
            e.printStackTrace();
        }
        return valueAsString;
    }
}
